class ShortSubsequence
{
public:
    int findShortest(vector<int> A, int n)
    {
        vector<int>B(n);
        for(int i = 0; i < n; i ++)
        {
            B[i] = A[i];
        }
        sort(B.begin(),B.end());
        int l = 0,r = n - 1;
        while (l < n  && A[l] == B[l])
        {
            l ++;
        }
        while (r > l && A[r] == B[r])
        {
            r --;
        }
        return r - l + 1;
    }
};
